/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qjs.smterp.jpa;

import java.io.Serializable;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.qjs.smterp.model.Unit;
@Repository("unitDao")
public class UnitDaoImpl extends AbstractHibernateDAOImpl<Unit, Long> implements UnitDao, Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected Class<Unit> getDomainClass() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Unit findByCode(String code) {
		// TODO Auto-generated method stub
		return (Unit)getSession().getNamedQuery("Unit.findByUnitCode").setParameter("unitCode", code).uniqueResult();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Unit> findByAll() {
		// TODO Auto-generated method stub
		return getSession().getNamedQuery("Unit.findAll").list();
	}

	@Override
	public Unit findById(int Id) {
		// TODO Auto-generated method stub
		return (Unit)getSession().getNamedQuery("Unit.findByUnitId").setParameter("unitId", Id).uniqueResult();
	}
    
}
